﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace giaodien
{
    public partial class ThongKeTonKho : Form
    {
        public ThongKeTonKho()
        {
            InitializeComponent();
        }
        static string Ten;
        static string Ma;
        DataTable dt = new DataTable();
        DataTable dstk = new DataTable();
        ConnectData obj = new ConnectData();
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            UI.MouseDown(e);
        }

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            UI.MouseMove(this, MousePosition.X, MousePosition.Y);
        }

        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            UI.MouseUp();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            UI.Exit(this);
        }

        private void ThongKeTonKho_Load(object sender, EventArgs e)
        {
            txtngaythongke.Text = DateTime.Now.ToShortDateString();
            txtnguoithongke.Text = Ten;
            dstk = obj.laydulieuBang("select * from sanpham");
            hienthitonkho(dstk);
        }
        public static void LayTen(string TenGui, string MaGui)
        {
            Ten = TenGui;
            Ma = MaGui;
        }
        void hienthitonkho(DataTable dt)
        {
            listView1.Items.Clear();
            foreach (DataRow dr in dt.Rows)
            {
                ListViewItem it = new ListViewItem();
                it.Text = dr["MaSP"].ToString();
                it.SubItems.Add(dr["TenSP"].ToString());
                it.SubItems.Add(dr["MaLoai"].ToString());
                if ((Boolean)dr["GioiTinhSP"] == true)
                    it.SubItems.Add("Nam");
                else
                    it.SubItems.Add("Nữ");
                it.SubItems.Add(dr["SoLuongTK"].ToString());
                listView1.Items.Add(it);

            }
        }
    }
}
